package com.godyao.mall.order.controller.admin;

import com.godyao.mall.core.model.ResultMsg;
import com.godyao.mall.order.model.Order;
import com.godyao.mall.order.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author godyao
 * @date 2022/4/1
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin")
public class OrderAdminController {
    private final IOrderService orderService;

    @PostMapping("/order")
    public ResultMsg makeOrder(@RequestBody Order order) {
        return ResultMsg.resultSuccess(orderService.makeOrder(order));
    }

    @DeleteMapping("/order/{id}")
    public ResultMsg<Void> makeOrder(@PathVariable Long id) {
        orderService.delById(id);
        return ResultMsg.resultSuccess();
    }
}
